package master2;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author chenyw
 * @date 2022/9/24 20:33
 */
public class M260singleNumber {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int i = 0;
        int[] nums = new int[n];
        while (i < n) {
            nums[i++] = scanner.nextInt();
        }
        int[] ints = singleNumber(nums);
        System.out.println(ints[0] + " " + ints[1]);
    }
    public static int[] singleNumber(int[] nums) {
        int tmp = 0;
        for (int i = 0; i < nums.length; i++) {
            tmp ^= nums[i];
        }
        int count = 0;
        while ((tmp & 1) == 0) {
            count++;
            tmp = tmp >> 1;
        }
        int left = 0;
        int right = 0;
        for (int i = 0; i < nums.length; i++) {
            tmp = nums[i];
            if ((tmp >> count & 1) == 1) {
                left ^= tmp;
            } else {
                right ^= tmp;
            }
        }
        int[] res = new int[2];
        res[0] = left;
        res[1] = right;
        return res;
    }
}
